<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
#d1 {
	width: 100px;
	height: 100px;
	border: 2px solid red;
	position: relative;
	top: 50px;
	left: 50px;
}

#d2 {
	width: 100px;
	height: 100px;
	border: 2px solid blue;
}

#d3 {
	width: 200px;
	height: 200px;
	background-color: red;
	position: relative;
}

#d3>div {
	width: 40px;
	height: 40px;
	background-color: blue;
	margin: 0 0 0 20px;
	position: absolute;
	top: 0;
	right: 0;
}

#d4 {
	width: 50px;
	height: 200px;
	background-color: purple;
	position: fixed;
	right: 0;
	top: 100px;
}
</style>
</head>
<body>
  <div id="d1"></div>
  <div id="d2"></div>
  <div id="d3">
    <div></div>
  </div>
  <div id="d4"></div>
</body>
</html>